﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FX.CC.Andon.Entity.DataManage;
using FX.CC.Andon.Entity.ReportManage;
using FX.CC.Andon.Service.DataManage;
using FX.CC.Andon.Utility.Json;

namespace FX.CC.Andon.Business.DataManage
{
    public class UnReliefAbnormalBusiness
    {
        private readonly UnReliefAbnormalService _dal = new UnReliefAbnormalService();

        public string GetUnReliefAbnormalList(AbnormalQcEntity qcmodel)
        {
            var total = _dal.GetUnReliefAbnormalCount(qcmodel);
            var list = _dal.GetUnReliefAbnormalList(qcmodel);
            return JsonHelper.Encode(total, list);

        }

        public bool RemoveUnReliefAbnormal(string id)
        {
            return _dal.RemoveUnReliefAbnormal(id);
        }

        public bool ModifyUnreliefAbnormal(string data)
        {
            var model = new UnreliefAbnormalEntity();
            var rows = (ArrayList)JsonHelper.Decode(data);
            foreach (Hashtable row in rows)
            {
                model.EventID = new Guid(row["EventID"].ToString());
                model.EndTime = Convert.ToDateTime(row["EndTime"].ToString());
                model.EndUserID = new Guid(row["StartUserID"].ToString());
            }
            return _dal.ModifyUnreliefAbnormal(model);
        }
    }
}
